package com.iss.lxhproject.service;

import com.iss.lxhproject.dao.UserDao;
import com.iss.lxhproject.entity.User;
import com.iss.lxhproject.model.UserWithRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    private UserDao userDao;

    public UserWithRole login(User user){
       return userDao.login(user);
    }

    public Boolean register(String u_id,String u_name,String u_psd,int u_roleid){
        Integer count = userDao.register(u_id,u_name,u_psd,u_roleid);
        if(count>0){
            return true;
        } else {
            return false;
        }
    }

    public Boolean CheckUserName(String u_name){
        User user = userDao.CheckUserNameExit(u_name);
        if(user==null){
            return false;
        }else{
            return true;
        }
    }

    public Boolean updateUserpwd(String u_name,String u_psd,String u_phone){
        Integer count= userDao.updateUserpwd(u_name,u_psd,u_phone);
        if(count>0){
            return true;
        }else {
            return false;
        }
    }
}
